package io_0929;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description: 字符流写文件
 * User: 86187
 * Date: 2022-10-07
 * Time: 21:47
 */
public class Demo3 {
    public static void main(String[] args) throws IOException {
        Writer writer = new FileWriter("./bbb.txt");

        // 写文件
        char[] buf = {'我','有','点','喜','欢','玛','依','拉'};
        writer.write(buf);
        String str = "你会喜欢我嘛?";
        writer.write(str);
        writer.close();

        // 读文件
        Reader reader = new FileReader("./bbb.txt");
        while (true) {
            int b = reader.read();
            if(b == -1) {
                break;
            }
            char ch = (char)b;
            System.out.print(ch + " ");
        }

        reader.close();
    }
}
